<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property string $event_name 
 * @property int $event_id 
 * @property string $submitter
 * @property int $submitter_id
 * @property string $file
 * @property string $remark 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at
 * @property int $deleted_at

 */
class EventInfo extends Model
{
    // 未删除枚举
    public const NO_DELETE = 0;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'event_info';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'event_id' => 'integer', 'submitter_id' => 'integer',
        'deleted_at'=> 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    // 关联文件
    public function files()
    {
        return $this->hasMany(File::class,'module_id',  'id')
            ->where('deleted_at', File::NO_DELETE)
            ->select(['file_name','size','suffix','created_at','module_id']);
    }

    public function filesPath()
    {
        return $this->hasMany(File::class,'module_id',  'id')
            ->where('deleted_at', File::NO_DELETE)
            ->select(['file_name','size','suffix','created_at','path','file_name','module_id']);
    }



}